export default {
  state: () => ({
    bookList: {},
  }),
  mutations: {
    SETBOOKLIST(state: any, data: any) {
      if (state.bookList.hasOwnProperty('' + data.service)) {
        //当存在
        if (state.bookList[data.service].length > 0) {
          let flag = false
          for (let i = 0; i < state.bookList[data.service].length; i++) {
            // console.log([data.path], data.path, state.bookList[data.service][i], [data.path].includes(state.bookList[data.service][i]))
            if (data.path.includes(state.bookList[data.service][i])) {
              flag = true
            }
          }
          if (!flag) {
            state.bookList[data.service].push(data.path)
          }
        } else {
          state.bookList[data.service].push(data.path)
        }
      } else {
        //不存在直接推
        state.bookList[data.service] = []
        state.bookList[data.service].push(data.path)
      }
    },
    SLICETAB(state: any, data: any) {
      state.bookList[data.service].splice(data.index, data.length)
    },
    SETTAB(state: any, data: any) {
      state.bookList[data.service] = [data.path]
    },
    CLEARBOOKLIST(state: any) {
      state.bookList = {}
    }
  },
};
